package com.sanpu.kxe.business.card.view;

import android.content.Context;
import android.view.View;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.card.bean.BankInfoOutput;
import com.sanpu.kxe.business.card.contract.CardConfig;
import com.sanpu.kxe.business.card.contract.UpdateBankTelContract;
import com.sanpu.kxe.business.card.presenter.UpdateBankTelPresenter;
import com.sanpu.kxe.module.widget.EditTextWithDel;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Description：修改银行卡预留手机号
 * Created by 薛勇军 on 2018/7/25.
 */

public class UpdateBankTelActivity extends BaseTitleActivity implements UpdateBankTelContract.View {

    @Bind(R.id.phone)
    EditTextWithDel vPhone;

    private UpdateBankTelContract.Presenter mPresenter;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_update_bank_redtel;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("修改预留手机号");
        BankInfoOutput infoOutput = (BankInfoOutput)
                getIntent().getSerializableExtra(CardConfig.INTENT_BANKINFO_OUTPUT);
        mPresenter = new UpdateBankTelPresenter(this, infoOutput);
    }

    @OnClick({R.id.commit})
    public void onClick(View view) {
        if (view.getId() == R.id.commit) {
            mPresenter.onCommit(vPhone.getText().toString());
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }

    @Override
    public void setPresenter(UpdateBankTelContract.Presenter presenter) {
        this.mPresenter = presenter;
    }

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.onDestroyPresenter();
            mPresenter = null;
        }
    }
}
